package com.cn.busi;

import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.cn.model.User;
import com.cn.service.UserService;

/**
 * 
 * 【账户】业务控制器
 * 
 * @author ZSL
 *
 */
@RestController
@RequestMapping(value = "/api/v2")
@Api(description = "【账户信息】业务控制器")
public class UserController {

	@Autowired
	private UserService userService;
	
	/**
	 * 日志
	 */
	private Logger logger = LoggerFactory.getLogger(UserController.class);
	
	/**
	 * 
	 * 新增用户
	 * 
	 * @param user
	 */
	@RequestMapping(value = "/users", method = RequestMethod.POST)
	public void addUser(@RequestBody User user) {
		
		//userService.addUser(user);
		logger.info("增加用户信息："+user.toString());

	}

	
	/**
	 * 
	 * 删除用户
	 * 
	 * @param user
	 */
	@RequestMapping(value = "/users/{mobile}", method = RequestMethod.DELETE)
	public void delUser(@PathVariable("mobile") String mobile) {
		
		//userService.addUser(user);
		logger.info("删除用户信息："+mobile);

	}
	
	
	/**
	 * 
	 * 查询用户
	 * 
	 * @param user
	 */
	
	
	@RequestMapping(value = "/users/{username}",method = RequestMethod.GET)
	public User getUser(@PathVariable("username") String username) {
		
		logger.info("查询用户信息："+username);

		//return new User();
		return userService.queryUser(username);
		
	}
	
	/**
	 * 
	 * 修改用户
	 * 
	 * @param user
	 */
	@RequestMapping(value = "/users/{mobile}",method = RequestMethod.PUT)
	public void editUser(@PathVariable("mobile") String mobile,@RequestBody User user) {
		
		logger.info("修改用户信息："+user.toString());

//		user.setDevicenum(mobile);
//		userService.editUser(user);
	}

}